#include<iostream>
#include<string.h>
using namespace std;
class Solution {
public:
    bool isLongPressedName(string name, string typed) {
        int i=0,j=0;
        for(;i<name.size();i++)
        {
            int cnt=1;
            while(i<name.size()-1&&name[i]==name[i+1])
            {
                cnt++,i++;
            }
            while(j<typed.size()&&name[i]==typed[j])
            {
                j++,cnt--;
            }
            if(cnt>0)return false;
        }
        return i==name.size()&&j==typed.size();
    }
};


int main()
{
    Solution s1;
    s1.isLongPressedName("saeed","ssaaedd");
}